import axios from 'axios';
const state = {
  searchForm: {
    curPage: 1,
    pageSize: 10
  },
  listData: []
}


const actions = {
  dataList({
    state,
    commit
  }, params = {}) {
    console.log(state)
    let bones = new Promise((resolve, reject) => {
      return axios.post(
        state.API[params.API ]|| state.API.search, Object.assign({}, state.searchForm, params.data)).then((res) => {
          
          console.log(res)
          if (res.data.status == 200) {
          
          commit("updateInfo", ["listData", res.data.data.list]);
          let searchForm={
            "curPage": res.data.data.page.curPage,
            "pageSize": res.data.data.page.pageSize,
            "pageCount": res.data.data.page.pageCount
          }
          console.log(searchForm)
          commit("updateInfo", ["searchForm",searchForm]);
          resolve(res.data.data);

        } else {
          reject(res.data.message);
        }
      }).catch((err) => {
        reject(err.message);
      });
    });
    return bones;
  }
}
export default {
  state,
  actions
};
